'use strict';

/**
 * Config for the router
 */
angular.module('app')
    .run(
    ['$rootScope', '$state', '$stateParams',
        function ($rootScope, $state, $stateParams) {
            $rootScope.$state = $state;
            $rootScope.$stateParams = $stateParams;
        }
    ]
)
    .config(['$stateProvider', '$urlRouterProvider',
        function ($stateProvider, $urlRouterProvider) {

            $urlRouterProvider
                .otherwise('/access/login');
            $stateProvider
              //access
              .state('access', {
                  abstract:true,
                  url: '/access',
                  template: '<div class="h-full"><div ui-view class="fade-in-right-big smooth" ng-init="app.settings.headerFixed=false"></div> </div>'
              })


              .state('access.login', {
                  url: '/login',
                  templateUrl: 'tpl/access/login.html',
                  resolve: {
                      deps: ['uiLoad',
                          function (uiLoad) {
                              return uiLoad.load([
                                  'js/controllers/access/login.js',
                                  'js/services/access/login.js',
                                  'js/util/public_key.js',
                                  'js/util/jsencrypt.min.js',
                                  'css/content-css/access/login.css'
                              ]);
                          }]
                  }
              })

              .state('access.register',{
                  abstract:true,
                  url:'/register',
                  template: '<div ui-view class="fade-in-right-big smooth bg-white" ng-init="app.settings.headerFixed=false"></div>'

              })

              .state('access.register.baseinformation', {
                  url: '/baseinformation/:state',
                  templateUrl: 'tpl/access/register_baseinformation.html',
                  resolve: {
                      deps: ['uiLoad',
                          function (uiLoad) {
                              return uiLoad.load([
                                  'css/content-css/access/register.css',
                                  'js/controllers/access/register.js',
                                  'js/services/access/register.js',
                                  'js/util/public_key.js',
                                  'js/util/jsencrypt.min.js'
                              ]);
                          }]
                  }
              })

              .state('access.register.cost',{
                  url: '/cost/:state',
                  templateUrl: 'tpl/access/register_cost.html',
                  resolve: {
                      deps: ['uiLoad',
                          function (uiLoad) {
                              return uiLoad.load(['css/content-css/access/register.css','js/controllers/access/register.js','js/services/access/register.js']);
                          }]
                  }
              })

              .state('access.register.shop', {
                  url: '/shop/:state',
                  templateUrl: 'tpl/access/register_shop.html',
                  resolve: {
                      deps: ['uiLoad',
                          function (uiLoad) {
                              return uiLoad.load([
                                  'js/controllers/access/register.js',
                                  'js/services/access/register.js',
                                  'css/content-css/access/register.css'
                              ]);
                          }]
                  }
              })

                .state('access.register.business', {
                    url: '/business',
                    templateUrl: 'tpl/access/register_business.html',
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function ($ocLazyLoad) {
                                return $ocLazyLoad.load('angularFileUpload').then(
                                    function () {
                                        return $ocLazyLoad.load([
                                            'js/controllers/access/register.js',
                                            'js/services/access/register.js',
                                            'css/content-css/access/register.css',
                                            'css/content-css/upload/picture_upload.css'
                                        ]);
                                    }
                                );
                            }]
                    }
                })

              .state('access.forgetpassword', {
                  url: '/forgetpassword',
                  templateUrl: 'tpl/access/forget_password.html',
                  resolve: {
                      deps: ['uiLoad',
                          function (uiLoad) {
                              return uiLoad.load([
                                  'css/content-css/access/forgotpwd.css',
                                  'js/controllers/access/forget_password.js',
                                  'js/services/access/forget_password.js',
                                  'js/util/public_key.js',
                                  'js/util/jsencrypt.min.js'
                              ]);
                          }]
                  }
              })


              .state('access.register.type', {
                  url: '/type',
                  templateUrl: 'tpl/access/register_type.html',
                  resolve: {
                      deps: ['uiLoad',
                          function (uiLoad) {
                              return uiLoad.load([
                                  'css/content-css/access/register.css',
                              ]);
                          }]
                  }
              })


              .state('access.register.chain', {
                  url: '/chain/:state',
                  templateUrl: 'tpl/access/register_chain.html',
                  resolve: {
                      deps: ['uiLoad',
                          function (uiLoad) {
                              return uiLoad.load([
                                  'css/content-css/access/register.css',
                                  'js/controllers/access/register.js',
                                  'js/services/access/register.js'
                              ]);
                          }]
                  }
              })


                .state('access.register.improve', {
                    url: '/improve/:id',
                    templateUrl: 'tpl/access/register_improve.html',
                    resolve: {
                        deps: ['uiLoad',
                            function (uiLoad) {
                                return uiLoad.load([
                                    'css/content-css/access/register.css',
                                    'js/controllers/access/register.js',
                                    'js/services/access/register.js'
                                ]);
                            }]
                    }
                })

      }

    ]
);
